package mf.com.controller.sys;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import mf.com.Service.sys.SysMenuService;
import mf.com.entity.system.SysMenu;
import mf.com.vo.common.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: lmf
 * @Create: 2024/3/30 22:20
 * Description:  菜单控制层
 */
@RestController
@RequestMapping(value="/admin/system/sysMenu")
@Tag(name="菜单")
public class SysMenuController {
    @Resource
    private SysMenuService sysMenuService;

    @GetMapping("/findNodes")
    @Operation(summary = "查询树形结构菜单")
    public Result<List<SysMenu>>  findTreeMens(){
        return Result.success(sysMenuService.findAllMenu());
    }

    @PutMapping("/update")
    @Operation(summary = "修改菜单")
    public Result<Integer> update(@RequestBody SysMenu sysMenu){
        return Result.success(sysMenuService.updateMenu(sysMenu));
    }

    @PostMapping("/save")
    @Operation(summary = "新增菜单")
    public Result<Integer> save(@RequestBody SysMenu sysMenu){
        return Result.success(sysMenuService.addMenu(sysMenu));
    }

    @DeleteMapping("removeById/{id}")
    @Operation(summary = "删除菜单")
    public Result<Integer> removeById(@PathVariable("id") Integer id){
        return Result.success(sysMenuService.delete(id));
    }

}
